// Copyright 2012 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
{namespace gitiles}

import * as common from 'com/google/gitiles/templates/Common.soy';

/**
 * List of all refs in a repository.
 */
{template refsDetail stricthtml="false"}
  {@param repositoryName: ?}  /** name of this repository. */
  {@param? menuEntries: ?}  /** menu entries. */
  {@param? customVariant: ?}  /** variant name for custom styling. */
  {@param breadcrumbs: ?}  /** breadcrumbs for this page. */
  {@param branches: ?}  /** list of branch objects with url, name, and isHead keys. */
  {@param tags: ?}  /** list of tag objects with url and name keys. */
{call common.header}
  {param title: 'Refs' /}
  {param repositoryName: $repositoryName /}
  {param menuEntries: $menuEntries /}
  {param customVariant: $customVariant /}
  {param breadcrumbs: $breadcrumbs /}
{/call}

<div class="Refs">
  {if length($branches)}
    {call refList}
      {param type: 'Branches' /}
      {param refs: $branches /}
    {/call}
  {/if}

  {if length($tags)}
    {call refList}
      {param type: 'Tags' /}
      {param refs: $tags /}
    {/call}
  {/if}
</div>

{call common.footer}
  {param customVariant: $customVariant /}
{/call}
{/template}

/**
 * List of a single type of refs
 */
{template refList}
  {@param type: ?}  /** name of this type of refs, e.g. "Branches" */
  {@param refs: ?}  /** list of branch objects with url, name, and optional isHead keys. */
  <div class="RefList">
    <h3 class="RefList-title">{$type}</h3>
    <ul class="RefList-items">
    {for $ref in $refs}
      <li class="RefList-item"><a href="{$ref.url}">{$ref.name}</a></li>
    {/for}
    </ul>
  </div>
{/template}
